<template>
  <el-dialog
    custom-class="dialog-class"
    :show-close="false"
    v-model="dialogVisible"
    :width="width"
  >
    <div class="header" v-if="headerStatus">
      <div class="headerName">{{ title }}</div>
      <el-icon size="24" @click="closeChange" style="cursor: pointer">
        <Close />
      </el-icon>
    </div>
    <el-divider v-if="headerStatus" />
    <slot v-if="dialogVisible"></slot>
  </el-dialog>
</template>
<script setup>
import { ref } from 'vue';
import bus from '@/utils/bus.js';

const dialogVisible = ref(false);
const { width, title, isSendBus } = defineProps({
  title: {
    type: String, // 接收的参数类型
    default: '默认文字', //默认值
  },
  width: {
    type: String,
    default: '1200',
  },
  headerStatus: {
    type: Boolean,
    default: true,
  },
  isSendBus: {
    type: Boolean,
    default: false,
  },
});

function openChange() {
  dialogVisible.value = true;
}

function closeChange() {
  dialogVisible.value = false;
  if (isSendBus) {
    bus.emit('refreshList');
  }
}
defineExpose({
  openChange,
  closeChange,
});
</script>
<style lang="scss">
.dialog-class {
  border-radius: 6px;

  .el-dialog__header {
    display: none;
  }
}
</style>
<style lang="scss" scoped>
.header {
  display: flex;
  justify-content: space-between;

  .headerName {
    font-size: 18px;
    font-family:
      PingFang SC-Medium,
      PingFang SC;
    font-weight: 600;
    color: #1d2129;
    line-height: 27px;
  }
}
</style>
